package com.it.config;

import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MQConfig {


    public static final String myPayExchange = "myPayExchange";
    public static final String myPayQueuey = "myPayQueuey";
    public static final String myPayRouting = "info.#.pay.#";


    @Bean(myPayExchange)
    public Exchange createPayExchange() {
        return ExchangeBuilder.topicExchange(myPayExchange).durable(true).build();
    }

    @Bean(myPayQueuey)
    public Queue createPayQueue() {
        return new Queue(myPayQueuey, true, false, false, null);
    }

    @Bean
    public Binding bindingPayQueueToExchange(@Qualifier(myPayExchange) Exchange exchange, @Qualifier(myPayQueuey) Queue queue) {
        return BindingBuilder.bind(queue).to(exchange).with(myPayRouting).noargs();
    }


}
